﻿using System;
using System.Web;
using System.Web.UI;
using System.Linq;
using Models;


public partial class Admin_JiFen_JFAdd : AdminBase
{
    public int _Id = 0;

    protected void Page_Load(object sender, EventArgs e)
    {

        Response.CacheControl = "no-cache";
        if (!string.IsNullOrEmpty(Request.Params["ID"]))
        {
            _Id = int.Parse(HttpContext.Current.Request.QueryString["ID"]);
        }

        if (!Page.IsPostBack)
        {

            if (_Id != 0)
            {
                ShowInfo(_Id);
            }
        }
    }
    private void ShowInfo(int _id)
    {

        Entities mydb = new Entities();
        {

            U_JF _lt = mydb.U_JF.First(p => p.JID == _id);
            txtName.Text = _lt.JFen.ToString();
            methods.JFTypeBind(this.ddlState, _lt.JGetWay);
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        Entities mydb = new Entities();
        {
            U_JF Lt = new U_JF();
            if (_Id != 0)
                Lt = mydb.U_JF.First(p => p.JID == _Id);

            Lt.JFen = int.Parse(txtName.Text.Trim());
            Lt.JGetWay = ddlState.SelectedValue;

            if (_Id == 0)
            {
                mydb.U_JF.Add(Lt);
                mydb.SaveChanges();
                Response.Write("<script> var Close=1;</script>");
            }
            else
            {
                mydb.SaveChanges();
                Response.Write("<script> var Close=1;</script>");
            }
        }
    }
}

